package com.spzx.channel.controller;

import com.spzx.channel.service.ChannelService;
import com.spzx.common.core.web.controller.BaseController;
import com.spzx.common.core.web.domain.AjaxResult;
import com.spzx.common.core.web.page.TableDataInfo;
import com.spzx.product.api.domain.Brand;
import com.spzx.product.api.domain.Category;
import com.spzx.product.api.domain.vo.ProductSkuBrandVo;
import com.spzx.product.api.domain.vo.SkuDetailVo;
import com.spzx.product.api.domain.vo.SkuSearchVo;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping
public class ChannelController extends BaseController {
    @Resource
    private ChannelService channelService;

    @GetMapping("/index")
    @Operation(summary = "首页")
    public AjaxResult indexHotDate() {
        ProductSkuBrandVo productSkuBrandVo = channelService.indexHotDate();
        return success(productSkuBrandVo);
    }

    @GetMapping("/category/tree")
    @Operation(summary = "分类树")
    public AjaxResult getCategoryTree() {
        List<Category> categoryTree = channelService.getCategoryTree();
        return success(categoryTree);
    }

    @GetMapping("/list/skuList/{pageNo}/{pageSize}")
    @Operation(summary = "分类列表")
    public TableDataInfo getSkuList(SkuSearchVo skuSearchVo) {
        return channelService.getSkuList(skuSearchVo);
    }

    @GetMapping("brand/getBrandAll")
    @Operation(summary = "商品品牌列表")
    public AjaxResult getBrandAll() {
        List<Brand> brands = channelService.getBrandAll();
        return success(brands);
    }

    @GetMapping("item/{skuId}")
    @Operation(summary = "商品详情")
    public AjaxResult getSkuDetail(@PathVariable("skuId") Long skuId) {
        SkuDetailVo skuDetailVo = channelService.getSkuDetail(skuId);
        return success(skuDetailVo);
    }
}
